﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoolCode.Entities
{
    public class InspectionSummary : List<SummaryInfo>//Dictionary<string, SummaryInfo>
    {
        public int Total
        {
            get;
            set;
            //get
            //{
            //    int total = this.Sum(c => c.Count);
            //    return total;
            //}
           // get { return GrandTotal == null ? 0 : GrandTotal.Count; }
        }

        public SummaryInfo Summary
        {
            get
            {
                SummaryInfo info = new SummaryInfo
                {
                     Key = string.Join(",", this.Select(c=> c.Key ).ToArray()), 
                      Count =this.Sum(c => c.Count),
                };
                info.Persent = info.Count  / (double)Total;
                return info;
            }
        }
    }

    public class SummaryInfo
    {
        public string Key { get; set; }
        public int Count { get; set; }
        public double Persent { get; set; }
    }

    public static class SummaryExtensions
    {
        public static InspectionSummary ToSummary(this List<Inspection> list)
        {
            return new InspectionSummary();
        }
    }
}
